<?php
namespace Home\Controller;
use Think\Controller;

class ExamController extends Controller{
    public function index($id){
        header("Content-type:text/html; charset=utf-8");
        $this->pd($id);
        $this->selelcts($id);
        $this->tk($id);
        $this->assign('id',$id);
        $this->display();
    }
    private function pd($id){
        $pd=M('pd');
        $list=$pd->join('ks_test ON ks_pd.tid = ks_test.id')->where('ks_pd.tid ='.$id)->field('ks_pd.*,ks_test.judge_point')->select();
//        var_dump($list);
//        exit();
        $count=$pd->where('`tid`='.$id)->count();
        $score=$list[0]['judge_point']/$count;
        $this->assign('pdlist',$list);
        $this->assign('pdcount',$count);
        $this->assign('pdscore',$score);
    }
    private function selelcts($id){
        $selects=M('selects');
        $list=$selects->join('ks_test ON ks_selects.tid = ks_test.id')->where('ks_selects.tid ='.$id)->field('ks_selects.*,ks_test.select_point')->select();
        $count=$selects->where('`tid`='.$id)->count();
        $score=$list[0]['select_point']/$count;
        $this->assign('selectslist',$list);
        $this->assign('selectscount',$count);
        $this->assign('selectsscore',$score);
    }
    private function tk($id){
        $tk=M('tk');
        $list=$tk->join('ks_test ON ks_tk.tid = ks_test.id')->where('ks_tk.tid ='.$id)->field('ks_tk.*,ks_test.blank_point')->select();
        $count=$tk->where('`tid`='.$id)->count();
        $score=$list[0]['blank_point']/$count;
        $this->assign('tklist',$list);
        $this->assign('tkcount',$count);
        $this->assign('tkscore',$score);
    }
}